home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / pcx_c.zip / PCXDISP.C < prev    next >
C/C++ Source or Header  |  1988-04-17  |  1KB  |  53 lines

  1. /*    PCXDISP.c   -  Load pictures into RAM and display them
  2. */
  3.  
  4.  
  5. #include "lib.h"
  6. #include "pcx.h"
  7.  
  8. extern int pcx_md;
  9.  
  10. void pcx_load_palette( pic )
  11. PCXPIC *pic;
  12. {
  13.     int p;
  14.  
  15.     if ( pcx_md )
  16.     {  /* this part NOT TESTED */
  17.        VGR_CPAL( pic->hdr.triple[0].red / 16, pic->hdr.triple[1].red / 32 );
  18.        return;
  19.     };
  20.  
  21.     for ( p=0; p < 16; p++ )
  22.        VGR_PALETTE( p, pic->hdr.triple[p].red   / 85,
  23.                        pic->hdr.triple[p].green / 85,
  24.                        pic->hdr.triple[p].blue  / 85 );
  25. }
  26.  
  27.  
  28. void pcx_showpic( pic, hoffs, voffs, load_palette_flg )
  29. int load_palette_flg, hoffs, voffs;
  30. PCXPIC *pic;
  31. {
  32.     int plane, row, nrows, nplan, nbytes;
  33.  
  34.     nrows = pic->hdr.y2 - pic->hdr.y1 +1;
  35.     nplan = pic->hdr.nplanes;
  36.     nbytes= pic->hdr.bpl;
  37.  
  38.     nrows  = nrows  > VGR_VRES ? VGR_VRES : nrows;
  39.     nbytes = nbytes > VGR_NBPL ? VGR_NBPL : nbytes;
  40.  
  41.     for ( plane = 0; plane < nplan; plane++ )
  42.     {  VGR_PLANE(plane ? plane : -0x0f);
  43.        for ( row = 0; row < nrows; row++ )
  44.           VGR_ROW( row, pic->rows[plane][row+voffs] + hoffs, nbytes );
  45.     };
  46.  
  47.     if ( load_palette_flg )
  48.        pcx_load_palette( pic );
  49. }
  50.  
  51.  
  52.  
  53.